<template>
  <div class="container">
    <div class="m-title">
      <span class="icon"></span>
      客户账户列表
      <el-button type="primary" class="add-btn" @click="goto">新建</el-button>
    </div>
    <el-form ref="form" :model="createNewAccountManagerForm" label-width="80px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="账户编码">
            <el-input
              v-model="createNewAccountManagerForm.acctCdLike"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="账户名称">
            <el-input
              v-model="createNewAccountManagerForm.acctNameLike"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="客户名称">
            <el-input
              v-model="createNewAccountManagerForm.custNameLike"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-button type="primary" @click="areatNewAccountQueryHandel"
            >查询</el-button
          >
        </el-col>
      </el-row>
    </el-form>
    <DicTable
      ref="myCustTableRef"
      class="m-table"
      align="center"
      border="full"
      max-height="500"
      stripe
      :columnData="createNewAccountTableColumns"
      :tableData="createNewAccountTableData"
      :loading="createNewAccountTableLoading"
      :currentPage="createNewAccountQuery.pageIndex"
      :pageSize="createNewAccountQuery.pageSize"
      :totalResult="createNewAccountQuery.rowCount"
      :pager="true"
      @on-page-change="areatNewAccountHandlePageChange"
    >
      <template #ifDefault="{ row }">
        <span v-if="row.ifDefault == '1'">是</span>
        <span v-else>否</span>
      </template>
      <template #acctBillingType="{ row }">
        <span v-if="row.acctBillingType == '10260001'">普通账户</span>
        <span v-else>专用账户</span>
      </template>
      <template #createDate="{ row }">
        <span>{{row.createDate ?
          row.createDate.substring(0, 4) +
          "-" +
          row.createDate.substring(4, 6) +
          "-" +
          row.createDate.substring(6, 8) : ''
        }}</span>
      </template>
      <template #opt="{ row }">
        <el-popover trigger="hover" placement="bottom" width="390">
          <el-row>
            <!--  操作日志 end-->
            <el-col :span="12">
              <dic-customer-btn-drawer
                title="查看付费记录"
                size="40%"
                btnShow="true"
                :isShow.sync="accountViewsPaymentHistoryIsShow"
                @drawShow="accountViewsPaymentHistoryHandel(row)"
                @closeDrawer="accountViewsPaymentSubmitChangeForm()"
              >
                <span slot="btnSlot" class="u-tabgs-btn"
                  ><span class="u-point"></span>查看付费记录</span
                >
                <div>
                  <DicTable
                    ref="commonRegionTable"
                    stripe
                    max-height="400"
                    highlight-current-row
                    :columnData="accountViewsPaymentHistoryColumns"
                    :tableData="accountViewsPaymentHistoryTableData"
                    :loading="accountViewsPaymentHistoryTableLoading"
                    :currentPage="accountViewsPaymentHistoryTablePage.pageIndex"
                    :pageSize="accountViewsPaymentHistoryTablePage.pageSize"
                    :pager="true"
                    :totalResult="accountViewsPaymentHistoryTablePage.rowCount"
                    @on-page-change="accountViewsPaymentHistoryHandlePageChange"
                  >
                  </DicTable>
                </div>
              </dic-customer-btn-drawer>
            </el-col>
            <el-col :span="12">
              <dic-customer-btn-drawer
                title="操作日志"
                size="60%"
                btnShow="false"
                :isShow.sync="operationLogIsShow"
                @drawShow="operationLogHandel(row)"
                @closeDrawer="operationLogSubmitChangeForm()"
              >
                <span slot="btnSlot" class="u-tabgs-btn"
                  ><span class="u-point"></span>操作日志</span
                >
                <div>
                  <DicTable
                    ref="commonRegionTable"
                    stripe
                    max-height="400"
                    align="center"
                    highlight-current-row
                    :columnData="operationLogColumns"
                    :tableData="operationLogTableData"
                    :loading="operationLogyTableLoading"
                    :currentPage="operationLogTablePage.pageIndex"
                    :pageSize="operationLogTablePage.pageSize"
                    :pager="true"
                    :totalResult="operationLogTablePage.rowCount"
                    @current-change="operationLogCurrentChangeEvent"
                    @on-page-change="operationLogHandlePageChange"
                  >
                    <template #slotName="{ row }">
                      <span>{{row.operationDate ?
                        row.operationDate.substring(0, 4) +
                        "-" +
                        row.operationDate.substring(4, 6) +
                        "-" +
                        row.operationDate.substring(6, 8) :''
                      }}</span>
                    </template>
                    <template #opt="{ row }">
                      <el-button
                        type="text"
                        v-if="
                          row.operationCd == 'updAcc' ||
                          row.operationCd == 'updAccTax'
                            ? true
                            : false
                        "
                        @click="detailDialog(row)"
                        >明细</el-button
                      >
                    </template>
                  </DicTable>
                </div>
                <el-dialog
                  width="60%"
                  title="修改明细"
                  :close-on-click-modal="false"
                  :visible.sync="innerVisible"
                  append-to-body
                >
                  <el-table
                    ref="detailData"
                    :data="
                      detailData.slice(
                        (dtablePage.pageIndex - 1) * dtablePage.pageSize,
                        dtablePage.pageIndex * dtablePage.pageSize
                      )
                    "
                    border
                    :header-cell-style="{
                      background: '#F2F2F2',
                      color: '#333',
                    }"
                    tooltip-effect="dark"
                    style="width: 100%"
                  >
                    <el-table-column label="序号" width="50" align="center">
                      <template scope="scope">
                          <span>{{scope.$index + (dtablePage.pageIndex - 1) * dtablePage.pageSize + 1}} </span>   
                        </template>
                    </el-table-column>
                    <el-table-column
                      label="属性名称"
                      prop="NAME"
                      align="center"
                      show-overflow-tooltip
                    >
                    </el-table-column>
                    <el-table-column
                      prop="NEW_VALUE"
                      label="新属性值"
                      align="center"
                      show-overflow-tooltip
                    >
                    </el-table-column>
                    <el-table-column
                      prop="OLD_VALUE"
                      label="原属性值"
                      align="center"
                      show-overflow-tooltip
                    >
                    </el-table-column>
                    <!-- <el-table-column
                      prop="TIME"
                      label="修改时间"
                      align="center"
                      show-overflow-tooltip
                    >
                    </el-table-column> -->
                  </el-table>
                  <el-pagination
                    background
                    @current-change="pageChange"
                    :current-page="parseInt(dtablePage.pageIndex)"
                    :page-size="parseInt(dtablePage.pageSize)"
                    layout="total, prev, pager, next, jumper"
                    :total="parseInt(detailData.length)"
                    class="m-pagination"
                  >
                  </el-pagination>
                </el-dialog>
              </dic-customer-btn-drawer>
            </el-col>
            <el-col :span="12">
              <dic-customer-btn-drawer
                title="审核历史"
                size="60%"
                btnShow="false"
                :isShow.sync="reviewHistoryIsShow"
                @drawShow="reviewHistoryLogHandel(row)"
              >
                <span slot="btnSlot" class="u-tabgs-btn"
                  ><span class="u-point"></span>审核历史</span
                >
                <div>
                  <DicTable
                    ref="commonRegionTable"
                    stripe
                    max-height="400"
                    highlight-current-row
                    align="center"
                    :columnData="reviewHistoryColumns"
                    :tableData="reviewHistoryTableData"
                    :loading="reviewHistoryTableLoading"
                    :currentPage="reviewHistoryTablePage.pageIndex"
                    :pageSize="reviewHistoryTablePage.pageSize"
                    :pager="true"
                    :totalResult="reviewHistoryTablePage.rowCount"
                    @on-page-change="reviewHistoryHandlePageChange"
                  >
                  </DicTable>
                </div>
              </dic-customer-btn-drawer>
            </el-col>
          </el-row>

          <span slot="reference" class="name-wrapper">
            <el-button type="text">查看</el-button>
          </span>
        </el-popover>
        <el-popover trigger="hover" placement="bottom" width="390">
          <el-row class="m-row">
            <el-col :span="12">
              <router-link
                class="u-tabgs-btn"
                :to="{
                  path: '/editCustAccount',
                  query: {
                    acctId: row.acctId,
                    custName: row.custName,
                    custId: row.custId,
                  },
                }"
                tag="a"
                ><span class="u-point"></span>修改账户信息</router-link
              >
            </el-col>
            <el-col :span="12">
              <div class="u-tabgs-btn" @click="modifyInfoAccountHandel(row)">
                <span class="u-point"></span>修改账户纳税信息
              </div>
              <el-dialog
                width="80%"
                title="修改账户纳税信息"
                :close-on-click-modal="false"
                :visible.sync="modifyInfoAccountIsShow"
                append-to-body
                class="m-dialog sh-dialog"
              >
                <el-form
                  :model="modifyTaxpayerInfoForm"
                  :rules="modifyTaxpayerInforules"
                  ref="modifyTaxpayerInforulesRef"
                  label-width="150px"
                >
                  <el-row>
                    <el-col :span="8">
                      <el-form-item label="客户名称">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.custName"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="是否一般纳税人:"
                        prop="generalTaxpayerFlag"
                        :required="true"
                      >
                        <el-select
                          v-model="modifyTaxpayerInfoForm.generalTaxpayerFlag"
                          @change="generalTaxpayerFlagChange"
                        >
                          <el-option
                            v-for="item in taxpayerInfoArr"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="审核人"
                        prop="auditor"
                        :required="true"
                      >
                        <dic-customer-select
                          :value="modifyTaxpayerInfoForm.auditor"
                          title="客户送审核"
                          size="50%"
                          ref="auditorRef"
                          v-if="auditorIsShow"
                          @inLoadAjax="modifyTaxpayerHandel"
                          @closeDialog="modifyTaxpayerCloseDialog"
                        >
                          <auditorDialog
                            v-if="auditIdComponentsIsShow"
                            @sunmitAuditIdHandel="sunmitAuditIdHandel"
                          ></auditorDialog>
                        </dic-customer-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <div class="m-title">
                        <span class="icon"></span>基本信息
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="纳税账户名称" prop="taxName">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxName"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务登记号"
                        prop="taxId"
                        :required="isRequired"
                      >
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxId"
                          @blur="registration"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务登记号所属省份"
                        prop="taxProvinceCode"
                        :required="isRequired"
                      >
                        <el-select
                          v-model="modifyTaxpayerInfoForm.taxProvinceCode"
                          placeholder="请选择"
                          :disabled="nsrDisabeld"
                        >
                          <el-option
                            v-for="item in selectInfo[0].val"
                            :key="item.code"
                            :label="item.name"
                            :value="item.code"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务登记联系电话"
                        prop="taxRelaTel"
                        :required="isRequired"
                      >
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxRelaTel"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务开户银行名称"
                        prop="taxBankName"
                        :required="isRequired"
                      >
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxBankName"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务开户银行帐号"
                        prop="taxBankAcct"
                        :required="isRequired"
                      >
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxBankAcct"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="16">
                      <el-form-item
                        label="税务登记地址"
                        prop="taxRelaAddr"
                        :required="isRequired"
                      >
                        <el-input
                          v-model="modifyTaxpayerInfoForm.taxRelaAddr"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="是否开增值税发票"
                        prop="vatInvoicesFlag"
                        :required="isRequired"
                      >
                        <el-select
                          v-model="modifyTaxpayerInfoForm.vatInvoicesFlag"
                          :required="isRequired"
                        >
                          <el-option
                            v-for="item in taxpayerInfoArr"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <div class="m-title">
                        <span class="icon"></span>状态信息
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="提交税务审核日期"
                        prop="submitDate"
                        :required="isRequired"
                      >
                        <el-date-picker
                          v-model="modifyTaxpayerInfoForm.submitDate"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择日期"
                          :picker-options="taxStartDate"
                        >
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="审核状态"
                        prop="audState"
                        :required="isRequired"
                      >
                        <el-select
                          v-model="modifyTaxpayerInfoForm.audState"
                          @change="audStateChange"
                        >
                          <el-option
                            v-for="item in audStateArr"
                            :key="item.code"
                            :label="item.name"
                            :value="item.code"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item
                        label="税务审核通过日期"
                        prop="approvalTime"
                        :required="isStateRequer"
                      >
                        <el-date-picker
                          v-model="modifyTaxpayerInfoForm.approvalTime"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="选择日期"
                          :picker-options="taxStartDate"
                        >
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="24">
                      <div class="m-title">
                        <span class="icon"></span>服务扩展信息
                      </div>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="通知短信手机号" prop="receiveMsgNum">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.receiveMsgNum"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="通知邮箱号" prop="receiveEmail">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.receiveEmail"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="取票方式" prop="takeType">
                        <el-select
                          v-model="modifyTaxpayerInfoForm.takeType"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in ticketsWayArr"
                            :key="item.code"
                            :label="item.name"
                            :value="item.code"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="邮寄地址" prop="billDeliverAddr">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.billDeliverAddr"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="邮编" prop="postcode">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.postcode"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8">
                      <el-form-item label="开票点" prop="invoiceAddr">
                        <el-input
                          v-model="modifyTaxpayerInfoForm.invoiceAddr"
                        ></el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="16">
                      <el-form-item label="修改纳税人证件">
                        <el-upload
                          class="upload-demo"
                          ref="custuploadRef"
                          action="#"
                          :on-change="custListonChange"
                          :on-remove="custListHandleRemove"
                          :on-exceed="custListHandleExceed"
                          :limit="1"
                          :http-request="custListUploadHttp"
                          :file-list="custTaxpayerfileList"
                          :before-upload="custListfileBeforeAvatarUpload"
                          :auto-upload="false"
                        >
                          <el-button slot="trigger" size="small" type="primary"
                            >选取文件</el-button
                          >
                          <el-button
                            style="margin-left: 10px"
                            size="small"
                            type="success"
                            @click="custListSubmitUpload()"
                            >上传到服务器</el-button
                          >
                          <el-button
                            v-if="loadShow"
                            style="margin-left: 10px"
                            size="small"
                            type="primary"
                            @click="downFiles()"
                            >下载文件</el-button
                          >
                        </el-upload>
                      </el-form-item>
                    </el-col>
                    <el-col :span="8"> </el-col>
                  </el-row>
                </el-form>
                <div class="btnBox">
                  <el-button type="primary" @click="modifyInfoAccountSubmitChangeForm(row)">确定</el-button>
                  <el-button type="info" @click="cancelDig">取消</el-button>
                </div>
              </el-dialog>
            </el-col>
            <el-col :span="12">
              <router-link
                class="u-tabgs-btn"
                :to="{
                  path: '/custProManagerInfo',
                  query: {
                    partyId: row.partyId,
                    staffId: user.staffId,
                    acctId: row.acctId,
                    custId: row.custId,
                    oldPartyCode: row.custNumber,
                    acctId: row.acctId,
                    acctCd: row.acctCd,
                    custName: row.custName,
                  },
                }"
                tag="a"
                ><span class="u-point"></span>管理对应省账户信息</router-link
              >
            </el-col>
          </el-row>
          <span slot="reference" class="name-wrapper">
            <el-button type="text">编辑</el-button>
          </span>
        </el-popover>
      </template>
    </DicTable>
  </div>
</template>

<script>
import DicTable from "@/components/public/DicTable";

import DicCustomerSelect from "@/components/customer/form/DicCustomerSelect";
import DicCustomerBtnDrawer from "@/components/customer/form/DicCustomerBtnDrawer";
import CreateNewAccountManager from "@/api/customer/CreateNewAccountManager";
import modificationDetails from "@/api/customer/modificationDetails";
import auditorDialog from "@/views/customer/components/auditorDialog";

import { mapState } from "vuex";
import validRules from "@/views/customer/valide/gaoyjValidRules.js";
export default {
  // import引入的组件需要注入到对象中才能使用
  components: {
    mapState,
    DicTable,
    DicCustomerBtnDrawer,
    DicCustomerSelect,
    auditorDialog,
  },
  // 这里存放数据
  data() {
    return {
      isShow: false,
      accountViewsPaymentHistoryIsShow: false,
      operationLogIsShow: false,
      reviewHistoryIsShow: false,
      modifyInfoAccountIsShow: false,
      delateBtnISShow: false,
      // 账户列表表单
      createNewAccountManagerForm: {
        // 账户编码
        acctCdLike: "",
        //账户名称
        acctNameLike: "",
        // 客户名称
        custNameLike: "",
      },
      acctId: "",
      // 下拉框的取值
      selectInfo: [
        {
          flag: "tax_province_code", //登记号所属省份
          val: [],
        },
      ],
      //  账户列表-表头
      createNewAccountTableColumns: [
        { field: "acctCd", title: "账户编码", width: 300, showOverflow: true },
        {
          field: "acctName",
          title: "账户名称",
          width: 350,
          showOverflow: true,
        },
        {
          slotName: "custName",
          title: "客户名称",
          width: 300,
          showOverflow: true,
        },
        {
          slotName: "acctBillingType",
          title: "账户类型",
          width: 150,
          showOverflow: true,
        },
        {
          slotName: "ifDefault",
          title: "是否默认账户",
          width: 150,
          showOverflow: true,
        },
        {
          slotName: "createDate",
          title: "创建时间",
          minWidth: 100,
          showOverflow: true,
        },
        { slotName: "opt", title: "操作", width: 250, fixed: "right" },
      ],
      // 账户列表-数据
      createNewAccountTableData: [],
      // 账户列表 load
      createNewAccountTableLoading: false,
      // 账户列表分页
      createNewAccountQuery: {
        pageIndex: 1,
        pageSize: 10,
        rowCount: 0,
        pageCount: 0,
      },

      // 查看付费记录
      accountViewsPaymentHistoryColumns: [
        {
          field: "custName",
          title: "客户名称",
          width: 300,
          showOverflow: true,
        },
        {
          field: "prodInstName",
          title: "销售品名称",
          width: 350,
          showOverflow: true,
        },
        { field: "accNum", title: "接入号码", width: 300, showOverflow: true },
        {
          field: "addressDesc",
          title: "地址",
          width: 150,
          showOverflow: true,
        },
      ],
      // 查看付费记录-数据
      accountViewsPaymentHistoryTableData: [],
      // 查看付费记录 load
      accountViewsPaymentHistoryTableLoading: false,
      // 查看付费记录分页
      accountViewsPaymentHistoryTablePage: {
        pageIndex: 1,
        pageSize: 5,
        rowCount: 0,
        pageCount: 0,
      },

      // 审核历史
      reviewHistoryColumns: [
        { type: "seq", width: 60, title: "序号", fixed: "left" },
        {
          field: "acctCd",
          title: "账户编码",
          width: 100,
          showOverflow: true,
          fixed: "left",
        },
        {
          field: "acctName",
          title: "账户名称",
          width: 200,
          showOverflow: true,
          fixed: "left",
        },
        {
          field: "auditKind",
          title: "审核类型",
          width: 100,
          showOverflow: true,
        },
        {
          field: "auditStatusCd",
          title: "审核状态",
          width: 150,
          showOverflow: true,
        },
        {
          field: "sendAuditByName",
          title: "创建人",
          width: 150,
          showOverflow: true,
        },
        {
          field: "sendAuditByCode",
          title: "创建人账号",
          width: 150,
          showOverflow: true,
        },
        {
          field: "sendAuditByOrgName",
          title: "创建人组织",
          width: 150,
          showOverflow: true,
        },
        {
          field: "auditorName",
          title: "审核人",
          width: 150,
          showOverflow: true,
        },
        {
          field: "auditorCode",
          title: "审核人账号",
          width: 150,
          showOverflow: true,
        },

        {
          field: "auditorOrgName",
          title: "审核人组织",
          width: 150,
          showOverflow: true,
        },
        {
          field: "auditResult",
          title: "审核结果",
          width: 150,
          showOverflow: true,
        },
        {
          field: "auditIdea",
          title: "审核意见",
          width: 150,
          showOverflow: true,
        },
        {
          field: "auditDate",
          title: "审核时间",
          width: 150,
          showOverflow: true,
        },
      ],
      // 查看付费记录-数据
      reviewHistoryTableData: [],
      // 查看付费记录 load
      reviewHistoryTableLoading: false,
      // 查看付费记录分页
      reviewHistoryTablePage: {
        pageIndex: 1,
        pageSize: 5,
        rowCount: 0,
        pageCount: 0,
      },
      uploadUrl: `${process.env.VUE_APP_CTX_CUST}/saveCustFile`,
      // 修改账务的税信息
      modifyTaxpayerInfoForm: {
        // 客户名称
        custName: "",
        // 是否一般纳税人
        generalTaxpayerFlag: "0",
        // 不用把神呢人的名臣传给后台-只需要传id
        auditor: "",
        auditorid: "",
        //纳税账户信息
        taxName: "",
        //税务登记号
        taxId: "",
        //税务登记号所属省份
        taxProvinceCode: "",
        // 税务登记联系电话
        taxRelaTel: "",
        // 税务开户银行名称
        taxBankName: "",
        // 税务开户银行帐号
        taxBankAcct: "",
        // 税务登记地址
        taxRelaAddr: "",
        // 是否开增值税发票
        vatInvoicesFlag: "",
        // 提交税务审核日期
        submitDate: "",
        // 税务审核通过日期
        approvalTime: "",
        // 通知短信手机号
        receiveMsgNum: "",
        // 通知邮箱号
        receiveEmail: "",
        // 取票方式
        takeType: "",
        // 邮寄地址
        billDeliverAddr: "",
        // 邮编
        postcode: "",
        // 开票点
        invoiceAddr: "",
        // 审核状态
        audState: "",
        // 纳税人标识
        taxpayerId: "",
        // 客户id主键-为了上传附件的时候使用
        custId: "",
        // 存储账户的id-为了上传附件的时候使用
        acctId: "",
        // 已上传纳税人证件
        papersFileName: "",
        // 已上传纳税人证件地址
        taxpayerPapers: "",
      },
      // 是否是必填项
      isRequired: false,
      modifyTaxpayerInforules: {
        generalTaxpayerFlag: [
          {
            validator: validRules.gaoyj_checkgeneralTaxpayerFlag,
            trigger: "change",
          },
        ],
        //  纳税账户名称
        taxName: [
          { required: true, message: "清填写纳税账户名称", trigger: "blur" },
        ],
        //审核人
        auditor: [
          {
            validator: validRules.gaoyj_checkedAuditor,
            trigger: "blur",
          },
        ],
        //  税务登记号
        taxId: [
          {
            validator: validRules.gaoyj_taxId,
            trigger: "blur",
          },
        ],
        // 税务登记号所属省份
        taxProvinceCode: [
          {
            validator: validRules.gaoyj_taxProvinceCode,
            trigger: "change",
          },
        ],
        // 税务登记联系电话
        taxRelaTel: [
          {
            validator: validRules.gaoyj_taxRelaTel,
            trigger: "blur",
          },
        ],
        // 税务开户银行名称
        taxBankName: [
          {
            validator: validRules.gaoyj_taxBankName,
            trigger: "blur",
          },
        ],
        // 税务开户银行帐号
        taxBankAcct: [
          {
            validator: validRules.gaoyj_taxBankAcct,
            trigger: "blur",
          },
        ],
        //
        taxRelaAddr: [
          {
            validator: validRules.gaoyj_taxRelaAddr,
            trigger: "blur",
          },
        ],
        // 是否开增值发票
        vatInvoicesFlag: [
          {
            validator: validRules.gaoyj_vatInvoicesFlag,
            trigger: "change",
          },
        ],
        // 提交税务审核日期
        submitDate: [
          {
            type: "date",
            validator: validRules.gaoyj_submitDate,
            trigger: "change",
          },
        ],
        // 审核状态
        audState: [
          {
            validator: validRules.gaoyj_audState,
            trigger: "change",
          },
        ],
        // 审核通过日期
        approvalTime: [
          {
            type: "date",
            validator: validRules.gaoyj_approvalTime,
            trigger: ['blur','change'],
          },
        ],
      },
      // 审核状态
      audStateArr: [
        {
          code: "0",
          name: "未通过",
        },
        {
          code: "1",
          name: "已通过",
        },
      ],
      // 是否是纳税人信息
      taxpayerInfoArr: [
        {
          value: "0",
          label: "否",
        },
        {
          value: "1",
          label: "是",
        },
      ],
      // 取票方式
      ticketsWayArr: [
        {
          code: "",
          name: "请选择",
        },
        {
          code: "1",
          name: "邮寄",
        },
        {
          code: "2",
          name: "客户自取",
        },
        {
          code: "3",
          name: "上门送票",
        },
      ],
      taxStartDate: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
      // 账户列表-操作日志
      operationLogColumns: [
        { type: "seq", width: 60, title: "序号", fixed: "left" },
        {
          field: "acctName",
          title: "账户名称",
          width: 200,
          showOverflow: true,
        },
        { field: "remark", title: "操作类型", width: 150, showOverflow: true },
        {
          field: "operationByName",
          title: "操作人",
          width: 100,
          showOverflow: true,
        },
        {
          field: "operationByCode",
          title: "操作人账号 ",
          width: 100,
          showOverflow: true,
        },
        {
          field: "operationByOrgName",
          title: "操作人组织",
          width: 100,
          showOverflow: true,
        },
        {
          slotName: "operationDate",
          title: "操作时间",
          width: 200,
          showOverflow: true,
        },
        { slotName: "opt", title: "操作", width: 100, showOverflow: true },
      ],
      // 查看付费记录-数据
      operationLogTableData: [],
      // 查看付费记录 load
      operationLogyTableLoading: false,
      // 查看付费记录分页
      operationLogTablePage: {
        pageIndex: 1,
        pageSize: 10,
        rowCount: 0,
        pageCount: 0,
      },
      row: "", //存储用于分页需要的数据
      innerVisible: false, //明细弹窗
      detailData: [], //明细数据列表
      dtablePage: {
        pageIndex: 1,
        pageSize: 5,
        rowCount: 0,
      },
      auditorIsShow: false,
      // 弹窗内-审核人的组件是否显示
      auditIdComponentsIsShow: false,
      // 上传附件
      custTaxpayerfileList: [],
      isStateRequer: false,
      loadShow: false, //下载按钮显示与隐藏
      nsrDisabeld: false,
      uploadFlag:false,//是否上传成功
    };
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  mounted() {
    this.$nextTick(function () {
      this.getAccountList();
      //  初始化下拉框的值
      this.initValue();
    });
  },
  // 方法集合
  methods: {
    // 获取账户列表
    async getAccountList() {
      let params = {
        staffId: this.user.staffId,
        acctCdLike: this.createNewAccountManagerForm.acctCdLike,
        acctNameLike: this.createNewAccountManagerForm.acctNameLike,
        custNameLike: this.createNewAccountManagerForm.custNameLike,
        pageIndex: this.createNewAccountQuery.pageIndex,
        pageSize: this.createNewAccountQuery.pageSize,
      };
      let result = await CreateNewAccountManager.getAccountList(params);
      if (result.code == 200) {
        let res = result.meta;
        if (res.accounts) {
          this.createNewAccountTableData = res.accounts;
          this.createNewAccountQuery.rowCount = Number(res.pageInfo.rowCount);
          this.createNewAccountQuery.pageCount ==
            Number(res.pageInfo.pageCount);
        } else {
          this.createNewAccountTableData = [];
          this.createNewAccountQuery.rowCount = Number(res.pageInfo.rowCount);
          this.createNewAccountQuery.pageIndex = 1;
        }
      }
    },
    // 纳税人信息切换
    generalTaxpayerFlagChange(val) {
      this.modifyTaxpayerInfoForm.generalTaxpayerFlag = val;
      if (this.modifyTaxpayerInfoForm.generalTaxpayerFlag == "0") {
        this.isRequired = false;
      } else {
        this.isRequired = true;
      }
      this.$refs.modifyTaxpayerInforulesRef.clearValidate();
    },
    // 账户列表-分页方法
    areatNewAccountHandlePageChange(val) {
      
      this.createNewAccountQuery.pageIndex = val.currentPage;
      this.createNewAccountQuery.pageSize = val.pageSize;
      this.getAccountList();
    },
    //  账户列表-查询
    areatNewAccountQueryHandel() {
      this.getAccountList();
    },
    // 跳转到新建账务信息页面
    goto() {
      this.$router.push({
        path: "/addCustAccount",
      });
    },
    // 账户列表-查看付费记录
    async getPayHisList() {
      let params = {
        acctId: this.row.acctId,
        pageIndex: this.accountViewsPaymentHistoryTablePage.pageIndex,
        pageSize: this.accountViewsPaymentHistoryTablePage.pageSize,
      };
      let result = await CreateNewAccountManager.getPayHis(params);
      if (result.code == 200) {
        if (result.meta.accountPayRecordList) {
          this.accountViewsPaymentHistoryTableData =
            result.meta.accountPayRecordList;
        }
        this.accountViewsPaymentHistoryTablePage.rowCount = Number(
          result.meta.pageInfo.rowCount
        );
        this.accountViewsPaymentHistoryTablePage.pageCount = Number(
          result.meta.pageInfo.pageCount
        );
      }
    },
    // 查看付费记录-分页方法
    accountViewsPaymentHistoryHandlePageChange(val) {
      // 查看付费记录
      this.accountViewsPaymentHistoryTablePage.pageIndex = val.currentPage;
      this.accountViewsPaymentHistoryTablePage.pageSize = val.pageSize;
      this.getPayHisList();
    },
    // 修改账户的税信息
    modifyInfoAccountSubmitChangeForm(row) {
      this.$refs.modifyTaxpayerInforulesRef.validate((valid) => {
        if (valid) {
          this.saveAccTax(row.acctId, row.custId);
        } else {
          return false;
        }
      });
    },

    // 查看付费记录
    accountViewsPaymentHistoryHandel(row) {
      this.row = row;
      this.accountViewsPaymentHistoryIsShow = true;
      this.accountViewsPaymentHistoryTablePage.pageIndex = 1;
      this.accountViewsPaymentHistoryTablePage.pageSize = 5;
      // 账户列表-查看付费记录
      this.getPayHisList();
    },
    // 查看付费记录-确定
    accountViewsPaymentSubmitChangeForm() {
      this.accountViewsPaymentHistoryIsShow = false;
    },
    //
    async modifyInfoAccountHandel(row) {
      let result = await CreateNewAccountManager.checkAccountAudit({accountId:row.acctId,auditKind:'1'});
      if(result.code == 200){
         if(result.meta.COUNT == 0){
            this.modifyTaxpayerInfoForm.custId = row.custId;
            this.modifyTaxpayerInfoForm.acctId = row.acctId;
            this.modifyInfoAccountIsShow = true;
            this.auditorIsShow = true;
            this.modifyInfoAccount(row);
         }else {
            this.$alert("该账户已在审核中，不能进行修改账户纳税信息操作！", "警告", {
              type: "warning",
              confirmButtonText: "关闭",
            }); 
         }
      }

    },
    // 修改账户的税信息
    async modifyInfoAccount(row) {
      let params = {
        acctId: row.acctId,
      };
      let result = await CreateNewAccountManager.getAccTaxDetail(params);
      if (result.code == 200) {
        // 客户名称
        this.modifyTaxpayerInfoForm.custName = row.custName;
        this.modifyTaxpayerInfoForm.taxpayerId = result.meta.taxPayerId;
        // 是否一般纳税人
        this.modifyTaxpayerInfoForm.generalTaxpayerFlag =
          result.meta.generalTaxpayerFlag ? result.meta.generalTaxpayerFlag : '0';
        if (this.modifyTaxpayerInfoForm.generalTaxpayerFlag == "0") {
          this.isRequired = false;
        } else {
          this.isRequired = true;
        }
        // 纳税账户名称
        this.modifyTaxpayerInfoForm.taxName = this.isNull(result.meta.taxName);
        // 税务登记号
        this.modifyTaxpayerInfoForm.taxId = this.isNull(result.meta.taxId);
        //  税务登记号所属省份
        this.modifyTaxpayerInfoForm.taxProvinceCode = this.isNull(
          result.meta.taxProvinceCode
        );
        // 税务登记联系电话
        this.modifyTaxpayerInfoForm.taxRelaTel = this.isNull(
          result.meta.taxRelaTel
        );
        // 税务开户银行名称
        this.modifyTaxpayerInfoForm.taxBankName = this.isNull(
          result.meta.taxBankName
        );
        // 税务开户银行帐号
        this.modifyTaxpayerInfoForm.taxBankAcct = this.isNull(
          result.meta.taxBankAcct
        );
        // 税务登记地址
        this.modifyTaxpayerInfoForm.taxRelaAddr = this.isNull(
          result.meta.taxRelaAddr
        );
        // 是否开增值税发票
        this.modifyTaxpayerInfoForm.vatInvoicesFlag = this.isNull(
          result.meta.vatInvoicesFlag
        );
        //  提交税务审核日期
        this.modifyTaxpayerInfoForm.submitDate =
          this.isNull(result.meta.submitDate) != ""
            ? result.meta.submitDate.substring(0, 4) +
              "-" +
              result.meta.submitDate.substring(4, 6) +
              "-" +
              result.meta.submitDate.substring(6, 8)
            : "";
        // 审核状态
        this.modifyTaxpayerInfoForm.audState = this.isNull(
          result.meta.audState
        );
        //  税务审核通过日期
        this.modifyTaxpayerInfoForm.approvalTime =
          this.isNull(result.meta.approvalTime) != ""
            ? result.meta.approvalTime.substring(0, 4) +
              "-" +
              result.meta.approvalTime.substring(4, 6) +
              "-" +
              result.meta.approvalTime.substring(6, 8)
            : "";
        // 通知短信手机号
        this.modifyTaxpayerInfoForm.receiveMsgNum = this.isNull(
          result.meta.receiveMsgNum
        );
        // 通知邮箱号
        this.modifyTaxpayerInfoForm.receiveEmail = this.isNull(
          result.meta.receiveEmail
        );
        // 取票方式
        this.modifyTaxpayerInfoForm.takeType = this.isNull(
          result.meta.takeType
        );
        // 邮寄地址
        this.modifyTaxpayerInfoForm.billDeliverAddr = this.isNull(
          result.meta.billDeliverAddr
        );
        // 邮编
        this.modifyTaxpayerInfoForm.postcode = this.isNull(
          result.meta.postcode
        );
        // 开票点
        this.modifyTaxpayerInfoForm.invoiceAddr = this.isNull(
          result.meta.invoiceAdd
        );
        // 已上传纳税人证件
        this.modifyTaxpayerInfoForm.papersFileName = this.isNull(
          result.meta.papersFileName
        );
        // 已上传纳税人证件
        this.modifyTaxpayerInfoForm.taxpayerPapers = this.isNull(
          result.meta.taxpayerPapers
        );
        if (
          this.modifyTaxpayerInfoForm.papersFileName != "" &&
          this.modifyTaxpayerInfoForm.taxpayerPapers != ""
        ) {
          this.custTaxpayerfileList = [
            {
              name: this.modifyTaxpayerInfoForm.papersFileName,
              url: this.modifyTaxpayerInfoForm.taxpayerPapers,
            },
          ];
          this.loadShow = true;
          this.uploadFlag = true;
        } else {
          this.custTaxpayerfileList = [];
          this.loadShow = false;
          this.uploadFlag = false;
        }
      }
    },
    //税务登记号与省份联动效果
    registration() {
      let proN = "";
      if (this.modifyTaxpayerInfoForm.taxId.length == 18) {
        proN = this.modifyTaxpayerInfoForm.taxId.substring(2, 4);
      } else if (
        this.modifyTaxpayerInfoForm.taxId.length == 15 ||
        this.modifyTaxpayerInfoForm.taxId.length == 20
      ) {
        proN = this.modifyTaxpayerInfoForm.taxId.substring(0, 2);
      }
      switch (proN) {
        case "11":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8110100";
          this.nsrDisabeld = true;
          break;
        case "12":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8120000";
          this.nsrDisabeld = true;
          break;
        case "13":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8130000";
          this.nsrDisabeld = true;
          break;
        case "14":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8140000";
          this.nsrDisabeld = true;
          break;
        case "15":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8150000";
          this.nsrDisabeld = true;
          break;
        case "21":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8210000";
          this.nsrDisabeld = true;
          break;
        case "22":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8220000";
          this.nsrDisabeld = true;
          break;
        case "23":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8230000";
          this.nsrDisabeld = true;
          break;
        case "31":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8310100";
          this.nsrDisabeld = true;
          break;
        case "32":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8320000";
          this.nsrDisabeld = true;
          break;
        case "33":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8330000";
          this.nsrDisabeld = true;
          break;
        case "34":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8340000";
          this.nsrDisabeld = true;
          break;
        case "35":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8350000";
          this.nsrDisabeld = true;
          break;
        case "36":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8360000";
          this.nsrDisabeld = true;
          break;
        case "37":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8370000";
          this.nsrDisabeld = true;
          break;
        case "41":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8410000";
          this.nsrDisabeld = true;
          break;
        case "42":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8420000";
          this.nsrDisabeld = true;
          break;
        case "43":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8430000";
          this.nsrDisabeld = true;
          break;
        case "44":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8440000";
          this.nsrDisabeld = true;
          break;
        case "45":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8450000";
          this.nsrDisabeld = true;
          break;
        case "46":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8460000";
          this.nsrDisabeld = true;
          break;
        case "50":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8500000";
          this.nsrDisabeld = true;
          break;
        case "51":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8510000";
          this.nsrDisabeld = true;
          break;
        case "52":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8520000";
          this.nsrDisabeld = true;
          break;
        case "53":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8530000";
          this.nsrDisabeld = true;
          break;
        case "54":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8540000";
          this.nsrDisabeld = true;
          break;
        case "61":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8610000";
          this.nsrDisabeld = true;
          break;
        case "62":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8620000";
          this.nsrDisabeld = true;
          break;
        case "63":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8630000";
          this.nsrDisabeld = true;
          break;
        case "64":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8640000";
          this.nsrDisabeld = true;
          break;
        case "65":
          this.modifyTaxpayerInfoForm.taxProvinceCode = "8650000";
          this.nsrDisabeld = true;
          break;
        default:
          this.modifyTaxpayerInfoForm.taxProvinceCode = "";
          this.nsrDisabeld = false;
          break;
      }
    },
    modifyTaxpayerHandel() {
      
      this.auditIdComponentsIsShow = true;
    },
    // 账户列表-操作日志
    operationLogHandel(row) {
      this.operationLogIsShow = true;
      this.acctId = row.acctId;
      this.operationLogTablePage.pageIndex = 1;
      this.operationLogTablePage.pageSize = 5;
      this.operationLogList(row);
    },

    // 操作日志
    async operationLogList(row) {
      let params = {
        acctId: this.acctId,
        pageIndex: this.operationLogTablePage.pageIndex,
        pageSize: this.operationLogTablePage.pageSize,
      };
      let result = await CreateNewAccountManager.getAccLogList(params);

      if (result.code == 200) {
        if (result.meta.executeSqlResp) {
          this.operationLogTableData = result.meta.executeSqlResp;
          this.operationLogTableData.forEach((item) => {
            item.operationDate = item.operationDate ? 
              item.operationDate.substring(0, 4) +
              "-" +
              item.operationDate.substring(4, 6) +
              "-" +
              item.operationDate.substring(6, 8) +
              " " +
              item.operationDate.substring(8, 10) +
              ":" +
              item.operationDate.substring(10, 12) +
              ":" +
              item.operationDate.substring(12, 14) : '';
          });
        }
        this.operationLogTablePage.rowCount = Number(
          result.meta.pageInfo.rowCount
        );
        this.operationLogTablePage.pageCount = Number(
          result.meta.pageInfo.pageCount
        );
      }
    },
    operationLogCurrentChangeEvent(val) {
      
    },
    // 操作日志-分页
    operationLogHandlePageChange(val) {
      this.operationLogTablePage.pageIndex = val.currentPage;
      this.operationLogTablePage.pageSize = val.pageSize;
      this.operationLogList(this.acctId);
    },
    // 初始化下卡框的值
    async initValue() {
      let response = "";
      this.selectInfo.forEach(async (item, index) => {
        response = await CreateNewAccountManager.initValue({ flag: item.flag });
        if (response.code == 200) {
          this.selectInfo[index].val = response.meta.customers;
        }
      });
    },
    // 审核历史-点击方法
    reviewHistoryLogHandel(row) {
      this.row = row;
      this.reviewHistoryIsShow = true;
      this.reviewHistoryTablePage.pageIndex = 1;
      this.reviewHistoryTablePage.pageSize = 5;
      this.reviewHistoryLogajax();
    },
    // 审核历史-ajax-初始化
    async reviewHistoryLogajax() {
      var that = this;
      let params = {
        acctId: this.row.acctId,
        custId: this.row.custId,
        pageIndex: this.reviewHistoryTablePage.pageIndex,
        pageSize: this.reviewHistoryTablePage.pageSize,
      };
      let result = await CreateNewAccountManager.getAccAuditHis(params);
      if (result.code == 200) {
        var res = result.meta;
        if (result.meta["accountAuditList"]) {
          this.reviewHistoryTableData = result.meta.accountAuditList;
          that.reviewHistoryTableData.forEach((element) => {
            
            if (element.auditKind == "1") {
              element.auditKind = "账户纳税信息修改审核";
            }
            // 审核状态
            if (element.auditStatusCd == "1300") {
              element.auditStatusCd = "审核通过";
            } else if (element.auditStatusCd == "1200") {
              element.auditStatusCd = "审核中";
            } else if (element.auditStatusCd == "1400") {
              element.auditStatusCd = "审核不通过";
            }
            element.auditDate = element.auditDate ?
              element.auditDate.substring(0, 4) +
              "-" +
              element.auditDate.substring(4, 6) +
              "-" +
              element.auditDate.substring(6, 8) +
              " " +
              element.auditDate.substring(8, 10) +
              ":" +
              element.auditDate.substring(10, 12) +
              ":" +
              element.auditDate.substring(12, 14) : '';
            // 审核结果
            if (element.auditResult == "1") {
              element.auditResult = "通过";
            } else if (element.auditResult == "2") {
              element.auditResult = "不通过";
            }
          });
        }
        this.reviewHistoryTablePage.rowCount = Number(
          result.meta.pageInfo.rowCount
        );
        this.reviewHistoryTablePage.pageCount = Number(
          result.meta.pageInfo.pageCount
        );
      }
    },

    // 审核历史-分页
    reviewHistoryHandlePageChange(val) {
      this.reviewHistoryTablePage.pageIndex = val.currentPage;
      this.reviewHistoryTablePage.pageSize = val.pageSize;
      this.reviewHistoryLogajax();
    },
    detailDialog(val) {
      this.innerVisible = true;
      if (val.operationCd == "updAcc") {
        this.getUpdCustModLog(val);
      } else if (val.operationCd == "updAccTax") {
        this.getUpdateTaxNewsLog(val);
      }
    },
    //账户信息修改明细
    async getUpdCustModLog(val) {
      let parmas = {
        accInfoLogId: val.accInfpLogId,
        custId: val.custId,
      };
      const response = await modificationDetails.getUpdCustModLog(parmas);
      if (response.code == 200) {
        this.detailData = response.meta.executeSqlResp;
      }
    },
    //账户纳税人信息修改明细
    async getUpdateTaxNewsLog(val) {
      let parmas = {
        accInfoLogId: val.accInfpLogId,
        custId: val.custId,
      };
      const response = await modificationDetails.getUpdateTaxNewsLog(parmas);
      if (response.code == 200) {
        this.detailData = response.meta.executeSqlResp;
      }
    },
    pageChange(val) {
      this.dtablePage.pageIndex = val;
    },
    // 判断值是否存在
    isNull(val) {
      if (
        val == "NaN" ||
        val == "null" ||
        val == "undefined" ||
        val == undefined
      ) {
        return (val = "");
      } else {
        return val;
      }
    },

    // 审核人选择确定之后-回显的审核人id值方法
    sunmitAuditIdHandel(val) {
      this.modifyTaxpayerInfoForm.auditor = val[1];
      this.modifyTaxpayerInfoForm.auditorid = val[0];
      this.$refs.auditorRef.drawer = false;
    },
    // 关闭审核人弹窗
    modifyTaxpayerCloseDialog() {
      this.auditIdComponentsIsShow = false;
    },
    // 修改纳税人证件-上传附件
    async custListUploadHttp(param) {
      var that = this;
      //判断上传文件数量
      if (this.custTaxpayerfileList.length == 0) {
        that.$message({
          message: "请选择导入的文件",
          type: "warning",
          duration: "2000",
        });
      } else {
        //创建FormData();主要用于发送表单数据
        let paramFormData = new FormData();
        var files = param.file;
        
        paramFormData.append("file", files);
        paramFormData.append("actType", "ADD");
        paramFormData.append("custId", this.modifyTaxpayerInfoForm.custId);
        paramFormData.append("acctId", this.modifyTaxpayerInfoForm.acctId);
        paramFormData.append("fileFlag", "accTax");
        paramFormData.append("staffId", this.user.staffId);
        paramFormData.append(
          "taxPayerId",
          this.modifyTaxpayerInfoForm.taxpayerId
        );
        const response = await CreateNewAccountManager.saveCustFile(
          paramFormData
        );
        if (response.code == 200) {
          if (response.meta.resultCode == 0) {
            this.modifyTaxpayerInfoForm.papersFileName = files.name;
            this.modifyTaxpayerInfoForm.taxpayerPapers =
              response.meta.taxpayerPapers;
              this.uploadFlag = true;
          }else {
              this.uploadFlag = false;
          }
          // 上传成功需要拿到返回的路径存储起来，然后进行下载
          // //
          // this.modifyTaxpayerInfoForm.taxpayerPapers=files.name;
          // this.$refs.custuploadRef.clearFiles();
        } else {
          this.$notify.error({
            title: "错误",
            message: response.msg,
          });
        }
      }
    },

    // 客户列表-上传附件-文件类型
    custListfileBeforeAvatarUpload(file) {
      let fileType = file.name.split(".").pop().toLowerCase();
      const isLt10M = file.size / 1024 / 1024 < 10;
      if ("bat" == fileType || "dll" == fileType || "zip" == fileType || "exe" == fileType) {
        this.$alert(
          "文件上传失败！上传文件的文件不能包含bat、dll、exe、zip类型！",
          "警告",
          {
            type: "warning",
            confirmButtonText: "关闭",
          }
        );
        return false;
      }
      if (!isLt10M) {
        this.$alert("上传文件大小不能超过 10MB!", "警告", {
          type: "warning",
          confirmButtonText: "关闭",
        });
        return false;
      }
    },
    // 客户列表-上传文件
    custListonChange(file, fileList) {
      this.custTaxpayerfileList = fileList;
      this.uploadFlag = false;
    },

    // 文件超出个数限制时的钩子
    custListHandleExceed(files, fileList) {
      this.$message.warning(`当前限制选择 1 个文件`);
    },
    // 客户列表上传附件-提交
    custListSubmitUpload() {
      this.$refs.custuploadRef.submit();
      this.loadShow = true;
    },
    // 删除文件
    custListHandleRemove(file, fileList) {
      if(this.uploadFlag){
        this.delateUploadFile();
      }
    },
    // 上传附件-删除的接口
    //删除附件
    async delateUploadFile() {
      let parmas = {
        actType: "MOD",
        staffId: this.user.staffId,
        custId: this.modifyTaxpayerInfoForm.custId,
        acctId: this.modifyTaxpayerInfoForm.acctId,
        taxPayerId: this.modifyTaxpayerInfoForm.taxpayerId,
        fileFlag: "accTax",
      };
      const response = await CreateNewAccountManager.modAccTaxFile(parmas);
      if (response.code == 200) {
        
        this.loadShow = false;
      } else {
        
        return false
      }
    },
    // 修改账户的税信息-保存
    async saveAccTax() {
      let params = {
        taxPayerId: this.modifyTaxpayerInfoForm.taxpayerId,
        acctId:this.modifyTaxpayerInfoForm.acctId ,
        custId:this.modifyTaxpayerInfoForm.custId,
        auditor: this.modifyTaxpayerInfoForm.auditorid,
        staffId: this.user.staffId,
        generalTaxpayerFlag: this.modifyTaxpayerInfoForm.generalTaxpayerFlag,
        taxName: this.modifyTaxpayerInfoForm.taxName,
        taxId: this.modifyTaxpayerInfoForm.taxId,
        taxProvinceCode: this.modifyTaxpayerInfoForm.taxProvinceCode,
        taxRelaTel: this.modifyTaxpayerInfoForm.taxRelaTel,
        taxBankName: this.modifyTaxpayerInfoForm.taxBankName,
        taxBankAcct: this.modifyTaxpayerInfoForm.taxBankAcct,
        taxRelaAddr: this.modifyTaxpayerInfoForm.taxRelaAddr,
        vatInvoicesFlag: this.modifyTaxpayerInfoForm.vatInvoicesFlag,
        submitDate: this.modifyTaxpayerInfoForm.submitDate,
        audState: this.modifyTaxpayerInfoForm.audState,
        approvalTime: this.modifyTaxpayerInfoForm.approvalTime,
        receiveMsgNum: this.modifyTaxpayerInfoForm.receiveMsgNum,
        receiveEmail: this.modifyTaxpayerInfoForm.receiveEmail,
        takeType: this.modifyTaxpayerInfoForm.takeType,
        billDeliverAddr: this.modifyTaxpayerInfoForm.billDeliverAddr,
        postcode: this.modifyTaxpayerInfoForm.postcode,
        invoiceAddr: this.modifyTaxpayerInfoForm.invoiceAddr,
      };
      let loadingInstance = this.$loading({ fullscreen: true });
      let result = await CreateNewAccountManager.saveAccTax(params);
      loadingInstance.close();
      // 账户保存
      if (result.code == 200) {
        if (result.meta.resultCode == 0) {
          this.$confirm("保存成功", "提示", {
            confirmButtonText: "确定",
            type: "success",
            center: true,
            showCancelButton: false,
            closeOnClickModal:false,
            showClose:false
          }).then(() => {
            this.createNewAccountQuery.pageIndex = 1;
            this.createNewAccountQuery.pageSize = 10;
            this.getAccountList();
            this.loadShow = false;
            this.modifyInfoAccountIsShow = false;
          });
        } else {
          this.$message({
            showClose: true,
            message: result.meta.resultMsg,
            type: "error",
          });
        }
      } else {
        this.$notify.error({
          itle: "错误",
          message: response.msg,
        });
      }
    },
    // 上传附件-下载-ajax
    async downFiles() {
      let params = {
        urlAddress: this.modifyTaxpayerInfoForm.taxpayerPapers,
        accName: this.modifyTaxpayerInfoForm.papersFileName,
      };
      const res = await CreateNewAccountManager.getCustFile(params);
      if (res.size > 0) {
        let url = window.URL.createObjectURL(new Blob([res])); //创建下载链接
        let link = document.createElement("a"); //创建a标签
        link.style.display = "none"; //将a标签隐藏
        link.href = url; //给a标签添加下载链接
        link.setAttribute(
          "download",
          this.modifyTaxpayerInfoForm.papersFileName
        ); // 此处注意，要给a标签添加一个download属性，属性值就是文件名称 否则下载出来的文件是没有属性的，空白白
        document.body.appendChild(link);
        link.click(); //执行a标签
      } else {
        this.$confirm(
          this.modifyTaxpayerInfoForm.papersFileName + "下载失败!",
          "提示",
          {
            confirmButtonText: "确定",
            showCancelButton: false,
            type: "warn",
            center: true,
          }
        );
      }
    },
    cancelDig(){
      this.modifyInfoAccountIsShow = false;
      this.$refs.modifyTaxpayerInforulesRef.resetField();
    },
    // 审核状态切换
    audStateChange(val) {
      if (val == "0") {
        this.isStateRequer = false;
      } else {
        this.isStateRequer = true;
      }
    },
    //
  },
  // 监听属性 类似于data概念
  computed: {
    ...mapState("user", ["user"]),
  },
  // 监控data中的数据变化
  watch: {},
  // 如果页面有keep-alive缓存功能，这个函数会触发
  activated() {},
  // 生命周期 - 挂载完成（可以访问DOM元素）
  beforeCreate() {},
  // 生命周期 - 数据挂载之前
  beforeMount() {},
  // 生命周期 - 数据更新之前
  beforeUpdate() {},
  // 生命周期 - 数据更新之后
  updated() {},
  // 生命周期 - 页面销毁之前
  beforeDestroy() {},
  // 生命周期 - 页面销毁完成
  destroyed() {},
};
</script>

<style scoped>
.u-tabgs-btn {
  display: inline-block;
  line-height: 0.3rem;
  cursor: pointer;
}
.container {
  padding: 0.2rem;
  background-color: #fff;
}
.m-title {
  margin-top: 0.1rem;
  margin-bottom: 0.1rem;
  color: #0052d9;
  font-size: 0.12rem;
}
.m-title .icon {
  float: left;
  display: block;
  width: 0.04rem;
  height: 0.12rem;
  background: rgb(245, 111, 60);
  margin-top: 0.02rem;
  margin-right: 0.1rem;
  font-size: 0.14rem;
}
.add-btn {
  float: right;
}
.m-table {
  margin-top: 0.3rem;
}
.u-point {
  /* display: inline-block; */
  float: left;
  width: 4px;
  height: 4px;
  background: #666;
  border-radius: 50%;
  margin-top: 0.13rem;
  margin-right: 0.1rem;
}
.el-dialog__body {
  padding: 0.1rem 0.2rem;
}
.m-pagination {
  margin: 20px auto;
  text-align: center;
}
.btnBox {
  width: 100%;
  padding-bottom: 20px;
  text-align: center;
}
</style>